package demo3;

public class Test {

        public static MySingList.ListNode mergeTwoLists(MySingList.ListNode list1, MySingList.ListNode list2) {
            MySingList.ListNode newHead = new MySingList.ListNode(-1);
            MySingList.ListNode tmp = newHead;
            while(list1 != null && list2 != null){
                if(list1.val < list2.val){
                    tmp.next = list1;
                    tmp = tmp.next;
                    list1 = list1.next;
                }else{
                    tmp.next = list2;
                    tmp = tmp.next;
                    list2 = list2.next;
                }
            }
            if(list1 == null){
                tmp.next = list2;
            }
            if(list2 == null){
                tmp.next = list1;
            }
            return newHead.next;
        }
    public static void main(String[] args) {
        MySingList mySingList1 = new MySingList();
        mySingList1.createList();
        mySingList1.addFirst(12);
        mySingList1.addFirst(23);
        mySingList1.addFirst(34);
        mySingList1.addFirst(45);
        mySingList1.addFirst(56);
        MySingList mySingList2 = new MySingList();
        mySingList2.addFirst(32);
        mySingList2.addFirst(342);
        mySingList2.addFirst(45);
        mySingList2.addFirst(4545);
        mySingList2.addFirst(563);
        MySingList.ListNode ret = mergeTwoLists(mySingList1.head,mySingList2.head);
        mySingList1.show();


    }
    public static void main1(String[] args) {
        MySingList mySingList = new MySingList();
        mySingList.createList();
        mySingList.addFirst(12);
        mySingList.addFirst(12);
        mySingList.addFirst(12);
        mySingList.addFirst(12);
        mySingList.addFirst(12);
        mySingList.addFirst(12);
        mySingList.addFirst(23);
        mySingList.addFirst(34);
        mySingList.addFirst(45);
        mySingList.addFirst(45);
        mySingList.addFirst(45);
        mySingList.addFirst(45);
        mySingList.addFirst(45);
        mySingList.addLast(78);
        mySingList.remove(12);
        mySingList.addIndex(1,999999);
        mySingList.removeAllKey(45);
        mySingList.removeAllKey(12);
        mySingList.show();
        System.out.println(mySingList.size());
        System.out.println(mySingList.contains(12));
        System.out.println(mySingList.contains(45));
        System.out.println(mySingList.contains(0));
        System.out.println("清空：");
        //mySingList.clear();
        mySingList.show();
        mySingList.reverseList();
        MySingList.ListNode ret = mySingList.reverseList();
        mySingList.show();
        System.out.println(ret);
    }

}
